package com.example.demo.repository;

import com.example.demo.entity.Book;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import org.springframework.data.repository.query.Param;
import org.springframework.data.domain.Pageable;

@Repository
public interface BookRepository extends JpaRepository<Book, Integer> {
    boolean existsByName(String name);

    boolean existsByIsbn(String isbn);

    // 添加模糊搜索方法
    @Query("SELECT b FROM Book b WHERE b.name LIKE %:name%")
    Page<Book> findByNameContaining(@Param("name") String name, Pageable pageable);
}